# -*- coding:UTF-8 -*-
"""
@Project : pythonProject
@File    : Register.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/7/7 下午9:15
"""
userInfo = [
    {'userAccount': 'Kate@qq.com', 'password': '123456'},
    {'userAccount': 'Mike@qq.com', 'password': '111111'}
]


def addUser(username, password):
    for user in userInfo:
        if user['userAccount'] == username:
            return -1 # 用户名已存在
    else:
        userInfo.append({'userAccount': username, 'password': password})
        return 1 # 加入成功


def register():
    username = input("Please input your username: ")
    password = input("Please input your password: ")
    if ('@' and '.com') in username and (len(password) == 6):
        return addUser(username, password)
    else:
        return -2 # 账号密码格式有错误

while 1:
    data = register()
    if data == -1:
        print("The username already exists. Please re-enter:")
    elif data == -2:
        print("The account username or password format is incorrect")
    elif data == 1:
        print(userInfo)
        print("Registration successful!")
        break